package mogiksaop.qliphoth.client.materials;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11;

//public static final abstract enum EnumMaterialOption

public enum EnumMaterialOption
{
	NO_LIGHTING {
		@Override
        public void begin(Object ... params) {
            FS.start_unlit();
        }

        @Override
        public void end(Object ... params) {
            FS.end_unlit();
        }
	}, WIREFRAME {
		@Override
        public void begin(Object ... params) {
            FS.start_wire();
        }

        @Override
        public void end(Object ... params) {
            GL11.glPopAttrib();
        }
	}, TRANSPARENCY {
		@Override
        public void begin(Object ... params) {
            FS.start_transparency(params);
        }

        @Override
        public void end(Object ... params) {
            FS.end_transparency();
        }
	}, NOCULL {
		@Override
        public void begin(Object ... params) {
            FS.enable_nocull();
        }

        @Override
        public void end(Object ... params) {
            FS.disable_nocull();
        }
	};

	public static int cubemapID;

	public abstract void begin(Object... paramVarArgs);

	public abstract void end(Object... paramVarArgs);

	static {
		cubemapID = 33986;
		// Byte code:
		// 0: new com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption$1
		// 3: dup
		// 4: ldc 'NO_LIGHTING'
		// 6: iconst_0
		// 7: invokespecial <init> : (Ljava/lang/String;I)V
		// 10: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.NO_LIGHTING :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 13: new com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption$2
		// 16: dup
		// 17: ldc 'WIREFRAME'
		// 19: iconst_1
		// 20: invokespecial <init> : (Ljava/lang/String;I)V
		// 23: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.WIREFRAME :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 26: new com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption$3
		// 29: dup
		// 30: ldc 'TRANSPARENCY'
		// 32: iconst_2
		// 33: invokespecial <init> : (Ljava/lang/String;I)V
		// 36: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.TRANSPARENCY :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 39: new com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption$4
		// 42: dup
		// 43: ldc 'NOCULL'
		// 45: iconst_3
		// 46: invokespecial <init> : (Ljava/lang/String;I)V
		// 49: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.NOCULL :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 52: iconst_4
		// 53: anewarray com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption
		// 56: dup
		// 57: iconst_0
		// 58: getstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.NO_LIGHTING :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 61: aastore
		// 62: dup
		// 63: iconst_1
		// 64: getstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.WIREFRAME :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 67: aastore
		// 68: dup
		// 69: iconst_2
		// 70: getstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.TRANSPARENCY :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 73: aastore
		// 74: dup
		// 75: iconst_3
		// 76: getstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.NOCULL :
		// Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 79: aastore
		// 80: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.$VALUES :
		// [Lcom/pixelmonmod/pixelmon/client/materials/EnumMaterialOption;
		// 83: ldc 33986
		// 85: putstatic
		// com/pixelmonmod/pixelmon/client/materials/EnumMaterialOption.cubemapID : I
		// 88: return
		// Line number table:
		// Java source line number -> byte code offset
		// #9 -> 0
		// #15 -> 13
		// #21 -> 26
		// #27 -> 39
		// #8 -> 52
		// #38 -> 83
		// #39 -> 88
	}

	private static final class FS {
		public static void start_wire() {
			GL11.glPushAttrib(2880);
			GL11.glPolygonMode(1032, 6913);
		}

		public static void start_unlit() {
			GlStateManager.disableLighting();
			(Minecraft.getMinecraft()).entityRenderer.disableLightmap();
		}

		public static void end_unlit() {
			GlStateManager.enableLighting();
			(Minecraft.getMinecraft()).entityRenderer.enableLightmap();
		}

		public static void start_transparency(Object[] actuallyAFloat) {
			GlStateManager.enableBlend();
			GlStateManager.blendFunc(770, 771);
			if (actuallyAFloat != null && actuallyAFloat.length > 0 && actuallyAFloat[0] instanceof Float) {
				float alpha = ((Float) actuallyAFloat[0]).floatValue();
				GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
			}
		}

		public static void end_transparency() {
			GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
			GlStateManager.disableBlend();
		}

		public static void enable_nocull() {
			GlStateManager.enableCull();
		}

		public static void disable_nocull() {
			GlStateManager.disableCull();
		}
	}
}
